#pragma once
#include "Singleton.h"
#include "MysqlDao.h"
#include "data.h"
#include "const.h"

class MysqlMgr :public Singleton<MysqlMgr>
{
	friend class Singleton<MysqlMgr>;
public:
    ~MysqlMgr();
    int RegUser(const std::string& name, const std::string& email, const std::string& pwd);
    bool CheckEmail(const std::string& name, const std::string& email);
    bool UpdataPwd(const std::string& name, const std::string& pwd);
    bool CheckPwd(const std::string& name, const std::string& pwd, UserInfo& userInfo);
    bool AddFriendApply(const int& fromuid, const int& touid);
    bool GetApplyList(int touid, std::vector<std::shared_ptr<ApplyInfo>>& applyList, int begin, int limit);
    std::shared_ptr<UserInfo> GetUser(int uid);
    std::shared_ptr<UserInfo> GetUser(const std::string& name);
    void AuthFriendApply(int uid, int touid);
    void AppendFriendInfo(int uid, int touid, std::string& name);
    bool GetFriendList(int self_id, std::vector<std::shared_ptr<UserInfo>>& user_list);
private:
    MysqlMgr();
    MysqlDao  _dao;
};

